<?php
require_once WACT_ROOT . '/db/db.inc.php';

class SportDate {


var $months_list = array('0'=>'(None)','1'=>'Jan','2'=>'Feb','3'=>'Mar','4'=>'April','5'=>'May', '6'=>'Jun', '7'=>'Jul', '8'=>'Aug', '9'=>'Sep', '10'=>'Oct', '11'=>'Nov', '12'=>'Dec');

	function &getMonthsList() {
    	$months=array('0'=>'(None)','1'=>'Jan','2'=>'Feb','3'=>'Mar','4'=>'April','5'=>'May', '6'=>'Jun', '7'=>'Jul', '8'=>'Aug', '9'=>'Sep', '10'=>'Oct', '11'=>'Nov', '12'=>'Dec');

    	return $months;
    }

    function &getMonths() {
    	$months=array('1'=>'Jan','2'=>'Feb','3'=>'Mar','4'=>'April','5'=>'May', '6'=>'Jun', '7'=>'Jul', '8'=>'Aug', '9'=>'Sep', '10'=>'Oct', '11'=>'Nov', '12'=>'Dec');

    	return $months;
    }

    function getMonth($i) {
    	$l =& SportDate::getMonths();
    	return $l[$i];
    }


    function &getWeekDays() {
    	$weekdays = array('1'=>'Sunday','2'=>'Monday','3'=>'Tuesday','4'=>'Wednesday','5'=>'Thursday', '6'=>'Friday', '7'=>'Saturday');

    	return $weekdays;
    }

    function getWeekDay($i) {
    	$l =& SportDate::getWeekDays();
    	return $l[$i];
    }

    function &getWeekNumbers() {
    	$weeks = array('1'=>'1st','2'=>'2nd','3'=>'3rd','4'=>'4th','5'=>'Last');

    	return $weeks;
    }

    function getWeekNumber($i) {
    	$l =& SportDate::getWeekNumbers();
        return $l[$i];
    }

    function &getMonthDays() {
    	for($i=1;$i<=31;$i++) {
    		$days[$i] = $i;
    	}
      	return $days;
    }

    function &getYears() {
    	$year = (integer)date('Y');
        for($i=$year;$i<=$year+10;$i++) {
    		$years[$i] = $i;
    	}
    	return $years;
    }

    function DbDate2Str($mydate) {
        $ts = strtotime($mydate);
       	$day = (integer)date('d',$ts);
       	$month = (integer)date('m',$ts);
       	$year = (integer)date('Y',$ts);
       	$str_date = $day.'/'.$month.'/'.$year;
       	return  $str_date;
    }

}

define("TIMEZONE_SERVER_OFFSET",0); // your server's offset from GMT 0
define("TIMEZONE_CLIENT_OFFSET",0); // your client's offset from GMT 0


class MyTimeZone {

   function timeNowLocal()  {
   	$ts = time();

   	$year =  gmdate('Y',$ts);
    $month =  gmdate('m',$ts);
    $day =  gmdate('d',$ts);
    $hour =  gmdate('H',$ts);
    $minutes =  gmdate('i',$ts);
    $sec =  gmdate('s',$ts);
    $ts = gmmktime( $hour+TIMEZONE_CLIENT_OFFSET, $minutes,$sec,$month, $day, $year,-1);
     //return time() + 3600 * TIMEZONE_CLIENT_OFFSET;
     return $ts;
   }

   // adjust the timestamp  from GMT
   function timeLocal($ts) {
    $year =  gmdate('Y',$ts);
    $month =  gmdate('m',$ts);
    $day =  gmdate('d',$ts);
    $hour =  gmdate('H',$ts);
    $minutes =  gmdate('i',$ts);
    $sec =  gmdate('s',$ts);

    $ts = gmmktime( $hour+TIMEZONE_CLIENT_OFFSET, $minutes,$sec,$month, $day, $year,-1);

   	 //$myTS = $TS + 3600 * TIMEZONE_CLIENT_OFFSET;
   	 //return $myTS;
   	 return  $ts;
   }

   // adjust the timestamp  from Local to GMT
   function timeGMT($TS) {
   	 $myTS = $TS + 3600 * TIMEZONE_SERVER_OFFSET;
   	 return $myTS;
   }


}






?>